package org.batatasframework.support.charts;

import java.util.ArrayList;
import java.util.List;

@Deprecated
public class ResultArrayParser {

//	private int size;
	
//	/** 从数据库查询出来的数据的字段的数量；注意这个长度不包括用于分组的字段 */
//	private int targetFieldSize;
	
	/** 用于分组的字段所在的位置 */
	private int groupIndex;
	
	private int[] targetFields;
	
	private List<ResultArrayItem> items = new ArrayList<>();
	
	public ResultArrayParser(int groupIndex, int startIndex, int endIndex){
		this.groupIndex = groupIndex;
		int j = 0;
		if(startIndex < groupIndex && groupIndex < endIndex){
			targetFields = new int[endIndex - startIndex - 1];
			for(int i = startIndex; i < endIndex; i++){
				if(i != groupIndex){
					targetFields[j++] = i;
				}
			}
		}else{
			targetFields = new int[endIndex - startIndex];
			for(int i = startIndex; i < endIndex; i++){
				targetFields[j++] = i;
			}
		}
//		this.targetFieldSize = targetFieldSize;
	}
	
	public ResultArrayParser(int groupIndex, int[] targetFields){
		this.groupIndex = groupIndex;
		this.targetFields = targetFields;
	}
	
	public String getName(Object[] sourceArray){
		return sourceArray[groupIndex].toString();
	}
	
	/** 被统计的字段的个数 */
	public int size(){
		return items.size();
	}
	
	public void add(int index, String name){}
}
